<!--
 * @Descripttion: 
 * @version: 
 * @Author: LLP
 * @Date: 2019-12-11 21:26:36
 * @LastEditors  : LLP
 * @LastEditTime : 2020-01-11 20:07:26
 -->
<template>
  <div class="wallet">
    <quotationLine :anTether="walletLine" @cycChartClick="cycChartClick"/>
    <div class="account-details">
      <h2>Asset</h2>
      <balance />
    </div>
  </div>
</template>

<script>
import { assetList } from '@/api/assets'
import { totalbalance } from "@/api/assets" 
import balance from "./components/balance.vue";
import quotationLine from "./components/quotationLine.vue";
export default {
  name: 'wallet',
  data() {
    return {
      dateType: 'week',
      activeName: "balance",
      comName: "balance",
      walletLine: {
        show: false,
        usd: "",
        linedata: {
          x:[],
          y:[]
        },
        color: '#6E8AC6'
      },
      assetInfo: ''
    };
  },
  components: {
    balance,
    quotationLine
  },
  created() {
    this.totalbalance()
  },
  mounted() {
    this.$nextTick(() => {
      this.assetListIifo()
    })
  },
  methods: {
    handleClick() {
      this.comName = this.activeName;
    },
    /**
     * [cycChartClick description]
     * 时间类型选择
     * ------------------------
     * @Author   LLP
     * @DateTime 2019-12-26T18:41:03+0800
     * @param    {[type]}                 name [description]
     * @return   {[type]}                      [description]
     */
    cycChartClick(name) {
      this.dateType = name.toLowerCase()
      this.totalbalance()
    },
    /**
     * [assetListIifo description]
     * 资产详情
     * ---------------------------
     * @Author   LLP
     * @DateTime 2019-12-26T18:39:29+0800
     * @return   {[type]}                 [description]
     */
    async assetListIifo() {
      const {data} = await assetList()
      if (data) {
       this.walletLine.usd = `USD ${data.assert_frozen_usdt + data.assert_avaliable_usdt}`
      }
    },
    /**
     * [totalbalance description]
     * 折线数据
     * ------------------------
     * @Author   LLP
     * @DateTime 2019-12-26T18:40:14+0800
     * @return   {[type]}                 [description]
     */
    async totalbalance() {
      let param = {
        type: this.dateType,
      }
      this.walletLine.linedata.x = []
      this.walletLine.linedata.y = []
      let { data } = await totalbalance(param)
      if (data.AssertList) {
        for (let item of data.AssertList) {
         this.walletLine.linedata.x.push(item.date)
         this.walletLine.linedata.y.push(item.usdt_token)
        }
      }
    }
  }
};
</script>

<style lang="less" scoped>
.wallet {
  .account-details {
    h2 {
      font-size: 28px;
      margin: 20px auto;
    }
  }
}
</style>


